package xyz.xtt.asset.request;

import java.util.Objects;

import io.swagger.annotations.ApiModelProperty;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author huqibo
 *
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
public class UpdateAssertRequest {
	@NotEmpty(message = "业务主键")
	private String busId;
	@ApiModelProperty("之前的价格")
	@NotNull(message = "之前的价格不能为空")
	@Min(value = 0, message = "之前的价格必须大于等于0")
	private Double oldPrice;
	@ApiModelProperty("新的价格")
	@NotNull(message = "目标价格不能为空")
	@Min(value = 0, message = "目标价格必须大于等于0")
	private Double newPrice;
	@ApiModelProperty("起售时间")
	private Long sellStart;

	public boolean checkNewPrice() {
		if (Objects.isNull(oldPrice) || Objects.isNull(newPrice)) {
			return false;

		}
		if (newPrice.compareTo(oldPrice) == 0) {
			return true;
		}
		return newPrice.floatValue() > 0;
	}

	public boolean checkSellStart() {
		if (Objects.isNull(sellStart)) {
			return false;
		}
		if (sellStart.compareTo(0L) == 0) {
			return true;
		}
		return String.valueOf(sellStart).length() == 13;
	}

}
